package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.service.SmsRocketMQService;
import com.itheima.health.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/mobile/validateCode")
public class SmsController {

    @DubboReference
    private SmsService smsService;
    @DubboReference
    private SmsRocketMQService smsRocketMQService;

    @PostMapping("/send")
    public Result send(@RequestParam("type") String validateCodeType,@RequestParam("telephone") String phone){
        /*
        * @Date: 4:52 下午 2021/1/10
        * @param: [validateCodeType, phone]
        * @return: com.itheima.health.entity.Result
        * @Description: 发送验证码
        */
        smsRocketMQService.sendValidateCode(validateCodeType,phone);

        return new Result(true, MessageConst.SEND_VALIDATECODE_SUCCESS);
    }
}
